//
//  PastExperienceCell.m
//  u76ho
//
//  Created by m-air-01 on 15/12/29.
//  Copyright © 2015年 LV. All rights reserved.
//

#import "PastExperienceCell.h"

@implementation PastExperienceCell

- (void)awakeFromNib {
    // Initialization code
    _btn.layer.masksToBounds = YES;
    _btn.layer.borderWidth = 0.5;
    _btn.layer.borderColor = [UIColorFromRGB(0x6cc844) CGColor];
}
-(void)setModel:(PastExperienceModel *)model
{
    _model = model;
    [_headerImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",U76HOURL,model.headpic]] placeholderImage:[UIImage imageNamed:@"在职公司－默认动态图"]];
    _firstLab.text = model.username;
    _secondLab.text = model.duty;
    
    NSString * date1 = [self dealDatewithStr:model.starttime];
    NSString * date2 = [self dealDatewithStr:model.endtime];
    
    NSLog(@"%@====%@",date2,model.endtime);
    
    if ([date2 isEqualToString:@"1970/01"]) {
        _thirdLab.text = [NSString stringWithFormat:@"%@ - 至今",date1];
    }else{
    
    _thirdLab.text = [NSString stringWithFormat:@"%@ - %@",date1,date2];
    }
    
    
    
    
}
-(NSString *)dealDatewithStr:(NSString *)str
{
    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
    formatter.dateFormat = @"yyyy/MM/dd";
    NSString * dataCh = str;
    NSString * dataStr = [dataCh substringToIndex:dataCh.length];
    NSDate * data = [[NSDate dateWithTimeIntervalSince1970:[dataStr integerValue]] dateByAddingTimeInterval:8*3600];
    NSString * lastStr = [NSString stringWithFormat:@"%@",data];
    NSArray * lastArr = [lastStr componentsSeparatedByString:@" "];
    NSString * dateStr = lastArr[0];
    
    NSArray * array = [dateStr componentsSeparatedByString:@"-"];
    NSMutableArray * mArr = [[NSMutableArray alloc]init];
    for (int i = 0; i<array.count-1; i++) {
        [mArr addObject:array[i]];
    }
    NSString * s = [mArr componentsJoinedByString:@"/"];
    
    return s;
}
- (IBAction)btnAction:(id)sender {
    if (_myDynaBlock) {
        _myDynaBlock();
    }
}
@end
